﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using TV;

namespace testNTD2
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {

            CBroadcastNoTouchDeployment configObject = null;
            configObject = new NtdConfig();
            MessageBox.Show(configObject.OriginalUrl, "Original");
            MessageBox.Show(configObject.TrimmedUrl, "Trimmed");
            //handleNoTouchDeployment();
            //MessageBox.Show(configObject.Arguments["silent"].ToString());
            //MessageBox.Show(configObject.Arguments["debug"].ToString());
            MessageBox.Show(configObject.Arguments);
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
        }

        private static void handleNoTouchDeployment()
        {

            MessageBox.Show("1");

            Object ntdUrl = AppDomain.CurrentDomain.GetData("APP_LAUNCH_URL");
            String m_appLaunchUrl = (ntdUrl != null ? ntdUrl.ToString() : String.Empty);

            MessageBox.Show("2");

            if (String.IsNullOrEmpty(m_appLaunchUrl))
            {
                return;
            }

            MessageBox.Show("3");

            Int32 startOfArgsIndex = m_appLaunchUrl.IndexOf('?');

            MessageBox.Show("4");

            if (startOfArgsIndex > 0)
            {
                MessageBox.Show("5");
                
                String m_trimmedUrl = m_appLaunchUrl.Substring(0, startOfArgsIndex);

                MessageBox.Show("6");

                //domain.SetData("APP_LAUNCH_URL", trimmedUrl);
                //AppDomain.CurrentDomain.SetData("APP_LAUNCH_URL", m_trimmedUrl);
                //AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", m_trimmedUrl + ".config");
                AppDomain.CurrentDomain.SetData("APP_LAUNCH_URL", m_trimmedUrl);
                AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", m_trimmedUrl + ".config");

                MessageBox.Show("7");

            }

        }


    }
}
